package com.d0323;

import java.io.*;

public class SerializableTest {
    public static void main(String[] args) throws Exception{
        //ByteArrayOutputStream baos = new ByteArrayOutputStream();
        FileOutputStream fos = new FileOutputStream(new File("src/com/d0323/wenjian.txt"));
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        Person person = new Person("jack",22,"jilin");
        oos.writeObject(person);//序列化
       // byte[] buffer = baos.toByteArray();
        oos.close();
        fos.close();

        FileInputStream fis = new FileInputStream(new File("src/com/d0323/wenjian.txt"));
        ObjectInputStream ois = new ObjectInputStream(new ObjectInputStream(fis));
        Person person1 = (Person) ois.readObject();//反序列化
        System.out.println(person1.getName()+"\t"+person1.getAge()+person1.getAddress());
    }
}
